package org.csu.zhangdian.controller;

import org.apache.catalina.Session;
import org.csu.zhangdian.domain.Account;
import org.csu.zhangdian.domain.LevelRate;
import org.csu.zhangdian.domain.LevelRule;
import org.csu.zhangdian.domain.MemberInfo;
import org.csu.zhangdian.service.LevelRateService;
import org.csu.zhangdian.service.LevelRuleService;
import org.csu.zhangdian.service.MemberInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import java.util.ArrayList;


@Controller
@RequestMapping("/level")
public class LevelController {

    @Autowired
    private LevelRateService levelRateService;
    @Autowired
    private LevelRuleService levelRuleService;
    @Autowired
    private MemberInfoService memberInfoService;

    @GetMapping("/ruleList")
    public String getLevel(LevelRule levelRule,Model model){

        model.addAttribute("levelRuleList",levelRuleService.getAllLevelRule());
        return "member/level";
    }



//
//    @GetMapping("/modifyLevelRule")
//    public String modifyLevelRule(int autgority,Model model){
//
//        Account account = accountService.getAccount(username, password);
//        if(getAuthority==null){
//            return "member/modifyLevelRuleUnsuccessfully";
//        }
//        else
//            return "member/modifyLevelRuleSuccessfully";
//    }




    @PostMapping("/huansuan")
    public String getRate(LevelRate levelRate, Model model){
        model.addAttribute("msg","修改成功,请及时提醒会员积分规则已更新");
//        return "member/modifySuccessfully";
        return "member/level";
    }











}
